package com.yiren.manager.service.impl.department;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiren.core.exception.MyException;
import com.yiren.core.service.GenericServiceImpl;
import com.yiren.core.utils.Favorites;
import com.yiren.entity.YrMealCard;
import com.yiren.entity.YrStaffInfo;
import com.yiren.manager.repository.department.YrStaffInfoRepository;
import com.yiren.manager.repository.messhall.YrMealCardRepositoty;
import com.yiren.manager.service.iface.department.YrStaffInfoService;

@Service("yrStaffInfoService")
public class YrStaffInfoServiceImpl extends GenericServiceImpl<YrStaffInfo, String> implements YrStaffInfoService{

	@Autowired
	private YrMealCardRepositoty mealCardRepository;
	
	@Autowired
	public YrStaffInfoServiceImpl(YrStaffInfoRepository repository) {
		super(repository);
	}
	
	@Transactional
	public void addByFavorites(Favorites entitys) throws MyException {
		YrStaffInfo staffInfo = entitys.getFavorite(YrStaffInfo.class);
		YrMealCard mealCard = entitys.getFavorite(YrMealCard.class);
		
		if(null!=mealCard){
			mealCardRepository.save(mealCard);	
		}
		
		this.repository.save(staffInfo);
	}

	public void modifyByFavorites(Favorites entitys) throws MyException {
		// TODO Auto-generated method stub
		
	}

}
